{extend name="base"}
{block name="style"}
<!-- 这里允许在引入一些样式头部 -->
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="{:_static()}/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all" />
<link rel="stylesheet" href="{:_static()}/css/source.css" media="all" />
<link rel="stylesheet" href="{:_static()}/css/common.css" media="all" />

{/block}

{block name="main"}
<style type="text/css">
	.ws-main{padding: 15px;}
	a:hover{color: inherit !important;}
	label{box-sizing: content-box;}
</style>

	<div class="childrenBody">
    <div class="layui-form">
      <div class="row row1">
            <div class="filter">
                <div class="source-head">
                    <label class="layui-form-label"><strong>素材导入</strong></label>
                </div>
                <div class="source-body">
                    <div class="source-cont">
                        <div class="layui-form-item tab-head">
                            <div class="layui-input-block">
                              <span class="filter-menu"><input type="radio" name="type" value="图文" title="图文" checked=""></span>
                              <span class="filter-menu"><input type="radio" name="type" value="视频" title="视频"></span>
                              <span class="filter-menu"><input type="radio" name="type" value="纯文字" title="纯文字"></span>
                            </div>
                        </div>
                        <div class="tab-body">
                            <div class="tab-cont on">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                      <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="可不填" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">文字</label>
                                    <div class="layui-input-block">
                                      <textarea placeholder="点击输入" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">图片</label>
                                    <input type="file" name="file" class="layui-upload-file" lay-title="上传图片">
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">评论内容</label>
                                    <div class="layui-input-block">
                                      <textarea placeholder="点击输入" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">素材小组</label>
                                    <div class="layui-input-inline">
                                      <select name="interest" lay-filter="aihao">
                                        <option value=""></option>
                                        <option value="0" selected="">默认分组</option>
                                        <option value="1">111</option>
                                        <option value="2">222</option>
                                      </select>
                                    </div>
                                    <button class="layui-btn layui-btn-primary">新建分组</button>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label"></label>
                                    <button class="layui-btn layui-btn-normal">导入</button>
                                </div>
                            </div>
                            <div class="tab-cont">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                      <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="可不填" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">文字</label>
                                    <div class="layui-input-block">
                                      <textarea placeholder="点击输入" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">视频</label>
                                    <input type="file" name="file2" lay-type="video" class="layui-upload-file" lay-title="上传视频">
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">评论内容</label>
                                    <div class="layui-input-block">
                                      <textarea placeholder="点击输入" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">素材小组</label>
                                    <div class="layui-input-inline">
                                      <select name="interest" lay-filter="aihao">
                                        <option value=""></option>
                                        <option value="0" selected="">默认分组</option>
                                        <option value="1">111</option>
                                        <option value="2">222</option>
                                      </select>
                                    </div>
                                    <button class="layui-btn layui-btn-primary">新建分组</button>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label"></label>
                                    <button class="layui-btn layui-btn-normal">导入</button>
                                </div>
                            </div>
                            <div class="tab-cont">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                      <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="可不填" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">文字</label>
                                    <div class="layui-input-block">
                                      <textarea placeholder="点击输入" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">评论内容</label>
                                    <div class="layui-input-block">
                                      <textarea placeholder="点击输入" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">素材小组</label>
                                    <div class="layui-input-inline">
                                      <select name="interest" lay-filter="aihao">
                                        <option value=""></option>
                                        <option value="0" selected="">默认分组</option>
                                        <option value="1">111</option>
                                        <option value="2">222</option>
                                      </select>
                                    </div>
                                    <button class="layui-btn layui-btn-primary">新建分组</button>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label"></label>
                                    <button class="layui-btn layui-btn-normal">导入</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="page"></div>
	</div>

<script type="text/babel" type="text/javascript">
layui.config({
    base : "js/"
}).use(['form','layer','jquery','laypage','upload'],function(){
    var form = layui.form(),
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        laypage = layui.laypage,
        $ = layui.jquery;


    //添加设备
    $(".deviceAdd_btn").click(function(){
        layer.prompt({title: '添加设备'}, function(val, index){
          // layer.msg('得到了'+val);
          layer.close(index);
        });
    })

    //全选
    form.on('checkbox(allChoose)', function(data){
        var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]:not([name="show"])');
        child.each(function(index, item){
            item.checked = data.elem.checked;
        });
        form.render('checkbox');
    });

    //通过判断文章是否全部选中来确定全选按钮是否选中
    form.on("checkbox(choose)",function(data){
        var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]:not([name="show"])');
        var childChecked = $(data.elem).parents('table').find('tbody input[type="checkbox"]:not([name="show"]):checked')
        if(childChecked.length == child.length){
            $(data.elem).parents('table').find('thead input#allChoose').get(0).checked = true;
        }else{
            $(data.elem).parents('table').find('thead input#allChoose').get(0).checked = false;
        }
        form.render('checkbox');
    })

    //是否展示
    form.on('switch(isShow)', function(data){
        var index = layer.msg('修改中，请稍候',{icon: 16,time:false,shade:0.8});
        setTimeout(function(){
            layer.close(index);
            layer.msg("展示状态修改成功！");
        },2000);
    })
 
    //操作
    $("body").on("click",".news_edit",function(){  //编辑
        layer.alert('您点击了文章编辑按钮，由于是纯静态页面，所以暂时不存在编辑内容，后期会添加，敬请谅解。。。',{icon:6, title:'文章编辑'});
    })

    $("body").on("click",".news_collect",function(){  //收藏.
        if($(this).text().indexOf("已收藏") > 0){
            layer.msg("取消收藏成功！");
            $(this).html("<i class='layui-icon'>&#xe600;</i> 收藏");
        }else{
            layer.msg("收藏成功！");
            $(this).html("<i class='iconfont icon-star'></i> 已收藏");
        }
    })

    $("body").on("click",".news_del",function(){  //删除
        var _this = $(this);
        layer.confirm('确定删除此信息？',{icon:3, title:'提示信息'},function(index){
            //_this.parents("tr").remove();
            for(var i=0;i<newsData.length;i++){
                if(newsData[i].newsId == _this.attr("data-id")){
                    newsData.splice(i,1);
                    newsList(newsData);
                }
            }
            layer.close(index);
        });
    })

    // 文件上传
    layui.upload({
      url: '上传接口url'
      ,success: function(res){
        console.log(res); //上传成功返回值，必须为json格式
      }
    });

    $(".tab-head .filter-menu").click(function(){
        var index = $(this).index();
        $(".tab-body .tab-cont").eq(index).addClass("on")
            .siblings().removeClass("on");
    });

})

</script>
{/block}